package com.ktg.mes.pro.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktg.common.core.redis.RedisCache;
import com.ktg.mes.pro.service.IProTaskDeviceProcessService;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;


/**
 * 创建生产关联（排产任务，生产设备，工序）对象 pro_task_device_process
 *
 * @author byteco
 * @date 2022-11-23
 */

@Data
@Accessors(chain = true)
@TableName("pro_task_device_process")
public class ProTaskDeviceProcess extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 工序项id */
    @TableId(value = "record_id", type = IdType.AUTO)
    private Long recordId;


    /** 任务id */
    @Excel(name = "任务id")
    private String taskId;


    /** 任务名称 */
    @Excel(name = "任务名称")
    private String taskName;


    /** 批号 */
    @Excel(name = "批号")
    private String batchNo;

    /** 生产订单ID */
    @Excel(name = "生产订单ID")
    private Long workorderId;

    /** 销售订单Id */
    @Excel(name = "销售订单Id")
    private String scaleId;


    /** 设备id */
    @Excel(name = "设备id")
    private Long deviceId;


    /** 设备名称 */
    @Excel(name = "设备名称")
    private String deviceName;


    /** 工艺流程中工序项配置的ID */
    @Excel(name = "工艺流程中工序项配置的ID")
    private Long routeProcessId;


    /** 工序项ID */
    @Excel(name = "工序项ID")
    private Long processId;


    /** 工序名称 */
    @Excel(name = "工序名称")
    private String processName;


    /** 工作类型 1正常 2返工 */
    @Excel(name = "工作类型 1正常 2返工")
    private String workType;


    /** 状态 1生产中 2生产完成*/
    @Excel(name = "状态 1生产中 2生产完成")
    private String status;


    /** 电表 */
    private String wattHourMeter;

    /** 温度计 */
    private String thermometer;

    /** 温湿计 */
    private String warmHumid;

    /**
     * 工艺配置参数
     */
    private String paramJson;

    public final static String statusProduct = "1";
    public final static String statusEnd = "1";


    /**
     *
     * @param redisCache
     * @param deviceId
     * @return
     */
    public static ProTaskDeviceProcess getMachineryNowTaskProcess(RedisCache redisCache,Long deviceId){
        String keyStr = "设备当前排产任务工艺:"+deviceId+"_"+ProTaskDeviceProcess.statusProduct;
        //获取当前设备生产的工单
        return redisCache.getCacheObject(keyStr);
    }

}
